package com.qfedu.point.service.impl;

import com.qfedu.common.core.entity.PointInfo;
import com.qfedu.common.core.entity.PointRule;
import com.qfedu.common.core.utils.UserUtils;
import com.qfedu.point.mapper.PointInfoMapper;
import com.qfedu.point.service.PointInfoService;
import com.qfedu.point.service.PointRuleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 以梦为马，以汗为泉，不忘初心，不负韶华
 *
 * @author zqh (ZQH)
 * @version 1.0
 * @date 2025/6/16 19:10
 */
@Service
public class PointInfoServiceImpl implements PointInfoService {
    @Resource
    private PointInfoMapper pointInfoMapper;

    //调用积分规则服务
    @Resource
    private PointRuleService pointRuleService;

    @Override
    public void remoteAddPoint(Integer pointType) {
        //根据积分类型查询积分规则
        Integer uid = UserUtils.getUid();
        PointRule pointRule = pointRuleService.ruleInfoByType(pointType);
        if (pointRule != null){
            PointInfo pointInfo = new PointInfo();
            pointInfo.setPointType(pointType);
            pointInfo.setPoint(pointRule.getPoint());
            pointInfoMapper.insert(pointInfo);
        }


    }
}